<include file="Public/head" title="礼品详情"/>
<include file="Public/back_head"/>
<div class="main">
    <div class="swiper-container">
        <div class="swiper-wrapper">
             <foreach name="data.goods_pics" item="val">
            <div class="swiper-slide"><div class="shop_chart" style="background-image: url({$val})"></div></div>
            </foreach>
        </div>
        <!-- 如果需要分页器 -->
        <div class="swiper-pagination"></div>
    </div>
    <div class="information">
        <div class="title">{$data.profile}</div>
        <div class="infor">
            <div class="l"><span>{$data.integral_price}</span><em>积分</em></div>
            <div class="r">库存<span class="index_list_num">{$data.store}</span></div>
        </div>
    </div>
    <!--没有的显示这个
    <div class="select_url">
        <a href="基本信息-添加收货地址.html"><span><i class="iconfont icon-weizhi"></i>添加收货地址</span><i class="iconfont icon-zuoyoujiantou2"></i></a>
    </div>
    -->
<input type="hidden" id="goods_id" value="{$data.id}" />
<input type="hidden" id="address_id" value="{$address.id}" />
    <if condition="$address neq null" >
    <a href="{:U('User/address',array('type'=>1))}">
        <div class="addrecipient_url">
            <div class="top"><span>{$address.name}</span><span>{$address.phone}</span></div>
            <div class="bottom"><i class="iconfont icon-weizhi1"></i>{$address.area}{$address.address}<i class="iconfont icon-zuoyoujiantou2"></i></div>
            <img src="__PUBLIC__/home/image/border_01.png" alt="" class="border_01">
        </div>
    </a>
    <else/>
     <div class="addrecipient_url">
      <a href="{:U('User/address',array('type'=>1))}">请先选择收货地址</a>
    </div>
    </if>
    <div class="empty"></div>
</div>
<button class="fiexd_button">立即兑换</button>

<script>
    var mySwiper = new Swiper ('.swiper-container', {
        direction: 'horizontal',
        loop: true,
        // 如果需要分页器
        pagination: '.swiper-pagination'
    });
    (function () {
        $(function () {
            $(".fiexd_button").click(function () {
               var goods_id = $('#goods_id').val();
               var address_id = $('#address_id').val();
               if(address_id ==''){
                layer.msg('请先选择收货地址');
                setTimeout("location.href='{:U('User/address',array('type'=>1))}'",1000);
                return false;
               }
                $.post(
                    "{:U('add')}",
                    {goods_id:goods_id,address_id:address_id},
                    function(data){
                        if(data.status == '1'){
                             layer.msg(data.info);
                             setTimeout("location.href='"+data.url+"'",1000);
                        }else{
                           layer.msg(data.info);
                        }
                    }
                )
            })
        })
    })(jQuery)
</script>
</body>
</html>